$(function(){
	var url={
		list:'{:url("adminapi/CarSell/sellList")}',//列表
		delete:'{:url("adminapi/CarSell/delete")}',//删除
		// http://127.0.0.1/adminapi/car_sell/delete.html?car_auction_id=14
		check:'{:url("adminapi/CarSell/checkSell")}',//审核
		//http://127.0.0.1/adminapi/car_sell/checkSell.html?car_auction_id=15&state=2
		//http://127.0.0.1/adminapi/car_sell/checkSell.html?car_auction_id=15&state=4
		//http://127.0.0.1/adminapi/car_sell/checkSell.html?car_auction_id=15&state=6
		//http://127.0.0.1/adminapi/car_sell/checkSell.html?car_auction_id=15&state=7&want_money=200
		//http://127.0.0.1/adminapi/car_sell/checkSell.html?car_auction_id=15&state=8&true_money=201
        add:'{:url("adminapi/CarSell/add")}',//增加
		// http://127.0.0.1/adminapi/car_sell/add.html?car_id=1&why=10
		upload:"{:url('adminapi/Upload/uploadImg')}"
	}

	var page=1;
	var tddata=[
		{
			key:'car_auction_id',
			type:1,
			url:''
		},{
			key:'number',
			type:2,
			url:'{:url("detail")}',
			id:137
		},{
			key:'brand',
			type:1,
			url:''
		},{
			key:'car_type_name',
			type:1,
			url:''
		},{
			key:'company_name',
			type:1,
			url:''
		},{
			key:'state2',
			type:1,
			url:''
		}];
	var addoperation=`<td>
						<div class="tpl-table-black-operation operate">
							<a href="javascript:;" class="tpl-table-black-operation-del scrap_close" data-method="delete">
								<i class="am-icon-pencil"></i> 删除
							</a>
						</div>
					</td>`
	$('.auction').on('click',function(){
		propcheck($(this))
	})
	var data={};
	data.page=page;
	data.pagenum=10;
	var where_json={};
	{if $Think.get.car_auction_id}
		where_json.car_auction_id=['like',"%{$Think.get.car_auction_id}%"];
	{/if}
	{if $Think.get.company_name}
		where_json.company_name=['like',"%{$Think.get.company_name}%"];
	{/if}
	{if $Think.get.number}
		where_json.number=['like',"%{$Think.get.number}%"];
	{/if}
	{if $Think.get.state}
		where_json.state=['in',"{$Think.get.state}"];
	{/if}
	
	data.where_json=JSON.stringify(where_json)
	ajaxauction(data)
	function ajaxauction(data){
		Load()
		$.ajax({
			type:"post",
			url:url.list,
			data:data,
			success:function(res){
				
				Load(1)
				if(res.code==1){
				console.log(res)

				for(var stateidx=0;stateidx<res.data.length;stateidx++){
					if(res.data[stateidx].state==1){
						res.data[stateidx].state2='待评估'
					}else if(res.data[stateidx].state==2){
						res.data[stateidx].state2='待审核'
					}else if(res.data[stateidx].state==3){
						res.data[stateidx].state2='评估不通过'
					}else if(res.data[stateidx].state==4){
						res.data[stateidx].state2='已审核'
					}else if(res.data[stateidx].state==5){
						res.data[stateidx].state2='审核不通过'
					}else if(res.data[stateidx].state==6){
						res.data[stateidx].state2='已登记'
					}else if(res.data[stateidx].state==7){
						res.data[stateidx].state2='已复审'
					}else if(res.data[stateidx].state==8){
						res.data[stateidx].state2='已拍卖'
					}
				}
				
				$('tbody').html(tbodymainf2(res.data, 1, tddata, addoperation,  'car_auction_id'))
				$('.pagination').html(pagechang1(res.count, 10, page))
				$('tbody tr').each(function(){
					var operate='';
					for(var idx=0;idx<res.data.length;idx++){
						
						if(res.data[idx].car_auction_id==$(this).data('id')){
							if(res.data[idx].state==1){
								operate=`<a class='auction_assess'>
										<i class="am-icon-pencil "></i> 评估
									</a>`
					
							}else if(res.data[idx].state==2){
								operate=`<a class='auction_check'>
											<i class="am-icon-pencil "></i> 审核
										</a>
									`
							}else if(res.data[idx].state==4){
								operate=`<a class='auction_resgister'>
										<i class="am-icon-pencil "></i> 登记
									</a>
									<a class='auction_detail' data-type='3'>
										<i class="am-icon-pencil "></i> 详情
									</a>
									`
							}else if(res.data[idx].state==6){
								operate=`
									<a class='second_check'>
										<i class="am-icon-pencil "></i> 复审
									</a>
									<a class='auction_detail' data-type='4'>
										<i class="am-icon-pencil "></i> 详情
									</a>
								`
							}else if(res.data[idx].state==8){
								operate=`<a class='auction_detail' data-type='5'>
										<i class="am-icon-pencil "></i> 详情
									</a>
								`
							}else {
								
							}
								
							}
						}
					$(this).find('.operate').append(operate)
					})
				for(var idx=0;idx<res.length;idx++){
					var operate='';
					
					$('.operate').eq(idx).append(operate)
					
				}
				$('.laquo').on('click',function(){
					page-=1;
					console.log(page)
					data.page=page
					ajaxauction(data)
				})
				$('.pageli').on('click',function(){
					page=$(this).html()
					data.page=page
					ajaxauction(data)
				})
				//下一页
				$('.raquo').on('click',function(){
					page+=1;
					data.page=page
					ajaxauction(data)
				});
				
				$('.scrap_close').on('click',function(){
					var main=getdetail($(this).closest('tr').data('id'),res.data,'car_auction_id')
					scrapclose($(this),main)
				})
				$('.auction_assess').on('click',function(){
					var main=getdetail($(this).closest('tr').data('id'),res.data,'car_auction_id')
					assess($(this),main)
				})
				$('.auction_check').on('click',function(){
					var main=getdetail($(this).closest('tr').data('id'),res.data,'car_auction_id')
					auctioncheck($(this),main)
				})
				$('.auction_resgister').on('click',function(){
					var main=getdetail($(this).closest('tr').data('id'),res.data,'car_auction_id')
					auctionresgister($(this),main)
				})
				$('.second_check').on('click',function(){
					var main=getdetail($(this).closest('tr').data('id'),res.data,'car_auction_id')
					secondcheck($(this),main)
				})
				$('.auction_detail').on('click',function(){
					var main=getdetail($(this).closest('tr').data('id'),res.data,'car_auction_id')
					detailauction($(this),main)
				})
			}else{
				Err(res.msg)
			}
			}
		});
	}
	//申请
	function propcheck(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'车辆拍卖申请',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['600px', '350px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap3">
	   			<div class='am-u-sm-12'>
	   				<div class="am-u-sm-12" style='margin-bottom:10px'>
		   				<div class='am-fl' style="padding:0 10px">
		   					<input type="hidden" class="CarId" name="car_id" value="{$item.car_id}" />
							<input type="text" class="am-form-field tpl-form-no-bg  car_number" value="{$item.car_number}" name="car_number" data-check='require' data-msg="车牌号不能为空" readonly="" />
		   				</div>
		   				<div class='am-btn-group am-fl am-btn-group-xs cl-p' >
		   					<button type="button" class='am-btn am-btn-default car_detail'>查看车辆详情</button>
		   				</div>
	   			
	   				</div>
	   				<div class="am-u-sm-12">
		   				<div class='am-u-sm-12'>
			   				<textarea style='height:150px' class='why' placeholder='请填写拍卖理由'></textarea>
		   				</div>
	   				</div>
	   				
	   			</div>
	   			
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius apply_ok'>提交申请</a>
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius apply_no'>取消</a>
	   			</div>
	   		</form>
   			</div>
   		`,
   		success:function(){
   			$('.car_number').on('click',function(){
				choosecar("{:url('car/index',['op'=>'search'])}")
			});
   			$('.car_detail').on('click',function(){
   				if($('.CarId').val()==""){
					Err('请选择车辆')
				}else{
					window.open("{:url('detail')}?_blank=1&car_id="+$('.CarId').val());  
//					choosecar("{:url('detail')}?car_id="+$('.CarId').val(),'车辆详情')
	   			}
   			})
   			$('.apply_ok').on('click',function(){
   			Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_id:$('.CarId').val(),
   						why:$('.why').val()
   					},
   					url:url.add,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('已提交申请')
   						ajaxauction(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
   			})
   			$('.apply_no').on('click',function(){
   				layer.close(auto)
   			})
   		}
   		})
	}
	//删除	
	function scrapclose(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:false,
   		skin: 'layui-layer-rim', //加上边框
   		area: ['200px', '100px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   				<div class='am-u-sm-12' style='text-align:center;margin-bottom:10px'>是否删除该报废单</div>
   				<div class='am-u-sm-12' style='text-align:center'>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius close_ok'>是</a>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius close_no'>否</a>
   				</div>
   			</div>
   		`,
   		success:function(){
   			
   			$('.close_ok').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_auction_id:obj.closest('tr').data('id')
   					},
   					url:url.delete,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						if(res.code==1){
   							ajaxauction(data)
   							Msg('删除成功')
   						}
   						layer.close(auto)
   					},
   					error:function(){
						Load(1)
   						Err('请求失败')
   						layer.close(auto)
   						
   					}
   				})
   			})
   			$('.close_no').on('click',function(){
   				layer.close(auto)
   			})
   		}
   		})
	}
	//评估
	function assess(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'拍卖评估',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['500px', '180px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   				<div style='text-align:center'>评估<a href='{:url("detail")}?_blank=1'  target="_blank">${main.number}</a>是否可以进行拍卖</div>
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
   					<a class='am-btn am-btn-sm am-btn-primary am-radius assess_ok'>通过</a>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius assess_no'>不通过</a>
	   			</div>
		   		
   			</div>
   		`,
   		success:function(){
   			
   			$('.assess_ok').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_auction_id:obj.closest('tr').data('id'),
   						state:2
   					},
   					url:url.check,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('评价通过')
   						ajaxauction(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
				
   			})
   			$('.assess_no').on('click',function(){
   				Msg('评估不通过')
   				obj.closest('.operate').parent().prev().html('评估不通过')
				obj.remove()
				layer.close(auto)
   			})
   		}
   		})
	}
	//审核
	function auctioncheck(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'拍卖申请审核',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['500px', '400px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
	   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap1">
		   			<div class='am-u-sm-12'>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
			   					车牌号:
			   				</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >
				   				<div class='am-fl' style='padding:0 10px 0 0'>
				   					${main.number}
				   				</div>
				   				<div class='am-btn-group am-fl am-btn-group-xs cl-p' >
				   					<button type="button" class='am-btn am-btn-default car_detail'>查看车辆详情</button>
				   				</div>
			   				</div>
		   				</div>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
			   					申请人:
			   				</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >${main.people?main.people:'-'}</div>
		   				</div>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
			   					申请时间:
			   				</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >
			   					${main.date}
			   				</div>
		   				</div>
		   				<div class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='font-size:14px;text-align:right'>
		   						拍卖原因:
		   					</div>
			   				<div class='am-u-sm-9' style='font-size:14px' >
			   					${main.why}
			   				</div>
		   				</div>
		   				
		   			</div>
		   			
		   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_ok'>同意拍卖</a>
	   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_no'>拒绝拍卖</a>
		   			</div>
		   		</form>
   			</div>
   		`,
   		success:function(){
   			$('.car_detail').on('click',function(){
   				choosecar("{:url('detail')}?car_id="+$('.CarId').val(),'车辆详情')
   			})
   			$('.scrap_ok').on('click',function(){
   				Load()
   				$.ajax({
   					type:'post',
   					data:{
   						car_auction_id:obj.closest('tr').data('id'),
   						state:4
   					},
   					url:url.check,
   					success:function(res){
   						Load(1)
   						console.log(res)
   						Msg('审核通过')
   						ajaxauction(data)
   						layer.close(auto)
   					},
   					error:function(){
   						Load(1)
   						Err('请求失败')
   					}
   				})
   			})
   			$('.scrap_no').on('click',function(){
   				Msg('拒绝拍卖')
   				obj.closest('.operate').parent().prev().html('审核不通过')
   				obj.remove()
   				layer.close(auto)
   			})
   		}
   		})
	}
	//登记
	function auctionresgister(obj,main){
		var auto = layer.open({
   		type: 1,
   		title:'车辆拍卖登记',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['650px', '480px'], //宽高
   		content: `
   			<div class='am-u-sm-12' style='padding:10px'>
   			<form class="am-form-inline tpl-form-border-form" enctype="multipart/form-data" data-check="1" data-ajax="1" id="scrap2">
	   			<div class='am-u-sm-12'>
	   				<div class="am-u-sm-12" style='margin-bottom:10px'>
	   				<div class="am-u-sm-12">
		   				<div class='am-u-sm-3' style='text-align:right'>
		   					${main.number}
		   				</div>
		   				<div class='am-btn-group am-fl am-btn-group-xs cl-p' >
		   					<button type="button" class='am-btn am-btn-default car_detail'>查看车辆详情</button>
		   				</div>
	   				</div>
	   				</div>
	   				<div class="am-u-sm-12" style='margin-bottom:10px'>
	   					<div class="am-u-sm-12" style='font-size:14px'>
		   					<div class='am-u-sm-3' style='text-align:right;padding:6px 10px'>
		   						成交金额:
		   					</div>
		   					<div class='am-u-sm-4 cl-p'>
		   						<input type='number' class='auction_money'/>
		   					</div>
		   					<div class='am-u-sm-5 cl-p'></div>
	   					</div>
	   				</div>
	   				<div class="am-u-sm-12" style='margin-bottom:10px;font-size:14px'>
	   					<div  class="am-u-sm-12">
		   					<div class='am-u-sm-3' style='text-align:right;padding:6px 10px'>
		   						成交方:
		   					</div>
		   					<div class='am-u-sm-4 cl-p'>
		   						<input type='text' class='auction_er'/>
		   					</div>
		   					<div class='am-u-sm-5 cl-p' ></div>
	   					</div>
	   				</div>
	   				
	   				<div class="am-u-sm-12 ">
	   					<div class='am-u-sm-3' style='text-align:right'>
		   					上传图片:
		   				</div>	
		   				<div class='am-u-sm-9 cl-p' >
							<div class="am-form-group file-w">
								<div style="width: 150px;height: 100px;">
									<img class="fileimg" data-magnify="1" src="{if $item.driving_license_img2}{:CxImg($item.driving_license_img2)}{else/}{$static_dir}/assets/img/noimg.gif{/if}" style="width: 100%;height: 100%;" />
								</div>
								<button type="button" data-type='file' class="am-btn am-btn-danger am-btn-sm imgfileadd"><i class="am-icon-cloud-upload"></i> 添加凭证图片</button>
								<input type="file"  class='scrap_file' style="display: none;">
							</div>
						</div>	
					</div>
	   			</div>
	   			
	   			<div class='am-u-sm-12' style="text-align:center;margin-top:10px">
   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_ok2'>登记</a>
   					<a class='am-btn am-btn-sm am-btn-primary am-radius scrap_no2'>取消</a>
	   			</div>
	   		</form>
   			</div>
   		`,
   		success:function(){
   			$('.car_detail').on('click',function(){
   				window.open("{:url('detail')}?_blank=1&car_id="+main.car_id)
   			})
   			$('.imgfileadd').on('click',function(){
   				$('.scrap_file').click()
   			})
   			$('.scrap_file').on('change',function(){
				var fil=$(this)[0].files[0];
				var that=this;
				var reader = new FileReader();
				reader.onload = function(evt) {
					$(that).closest('.file-w').find('.fileimg').attr('src',evt.target.result)
				}
				reader.readAsDataURL(fil);
			})
   			
   			$('.scrap_ok2').on('click',function(){
// 				Load()
   				var formData = new FormData();
   				var file = $('.scrap_file')[0].files[0]; 
				var name = $('.scrap_file').val();
				formData.append("image",file);
				formData.append("name",name);
   				$.ajax({
   					type:'post',
   					url:url.upload,
   					data:formData,
					processData : false, 
					contentType : false,
   					success:function(res1){
   						console.log(res1.image)
   						
		   				$.ajax({
		   					type:'post',
		   					data:{
		   						car_auction_id:obj.closest('tr').data('id'),
		   						state:6,
		   						true_money:$('.auction_money').val(),
		   						auction_er:$('.auction_er').val(),
		   						scrap_image:res1.image

		   					},
		   					url:url.check,
		   					success:function(res){
		   						Load(1)
		   						console.log(res)
		   						Msg('已确认')
		   						ajaxauction(data)
		   						layer.close(auto)
		   					},
		   					error:function(){
		   						Load(1)
		   						Err('请求失败')
		   					}
		   				})
   					}
   				})
// 				
   			})
   			$('.scrap_no2').on('click',function(){
   				
				layer.close(auto)
   			})
   		}
   		})
	}
	//二次审核
	function secondcheck(obj,main){
		var detail_cont=`<div class='am-u-sm-12' style='padding:10px;font-size:14px;height:100%'>
	   			<div class='am-u-sm-12 cl-p'  style='height:100%'>
	   				<div class='am-u-sm-6 cl-p'>
		   				<div class="am-u-sm-12 cl-p">
	   						<div class='am-u-sm-4' style='text-align:right'>
		   						车牌号:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						<a href='{:url("detail")}?car_id=${main.car_id}'  target="_blank">${main.number}</a>
		   					</div>
				   				
			   			</div>
			   			
		   				<div class="am-u-sm-12 cl-p">
		   					<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖申请人:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.people?main.people:'-'}
		   					</div>
		   					
			   			</div>
			   			<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						申请时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date}
		   					</div>
			   				
			   			</div>
			   			
			   			<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						审核时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   							${main.date_2}
		   					</div>
			   				
			   			</div>
			   			<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖成交方:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.auction_er}
		   					</div>
		   				</div>
		   				<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date_4}
		   					</div>
			   				
			   			</div>
		   				
		   				<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						登记时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date_6}
		   					</div>
			   				
			   			</div>
			   			<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						成交金额:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.true_money}
		   					</div>
		   					
			   			</div>
			   			<div class="am-u-sm-12 cl-p">
		   					<div class='am-u-sm-4 ' style='text-align:right'>
		   						拍卖理由:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.why}
		   					</div>
			   				<div class='am-u-sm-12'>
			   					
			   				</div>
		   				</div>
		   			</div>
		   			<div class='am-u-sm-6' style='height:80%;'>
		   				<img class='magnifyauction' src='{$static_dir}/assets/img/noimg.gif' alt="拍卖凭证" data-magnify='1' style='height:100%;width:100%;border:1px solid #999'>
		   			</div>
	   				<div class='am-u-sm-12' style='text-align: center;margin-top:10px'>
	   					<button class='am-btn am-btn-sm am-btn-primary second_check'>审核</button>
	   					<button class='am-btn am-btn-sm am-btn-primary'>取消</button>
	   				</div>
				</div>
   			</div>`
		var auto = layer.open({
	   		type: 1,
	   		title:'车辆复审',
	   		skin: 'layui-layer-rim', //加上边框
	   		area: ['600px', '400px'], //宽高
	   		content: detail_cont,
	   		success:function(){
	   			$('.car_detail').on('click',function(){
	   				choosecar("{:url('detail')}?_blank=1&car_id="+$('.CarId').val(),'车辆详情')
	   			})
	   			$('.second_check').on('click',function(){
	   				Load()
		   				$.ajax({
		   					type:'post',
		   					data:{
		   						car_auction_id:obj.closest('tr').data('id'),
		   						state:8
		   					},
		   					url:url.check,
		   					success:function(res){
		   						Load(1)
		   						console.log(res)
		   						Msg('复审通过')
		   						ajaxauction(data)
		   						layer.close(auto)
		   					},
		   					error:function(){
		   						Load(1)
		   						Err('请求失败')
		   					}
		   				})
	   			})
	   			$('.magnifyauction').on('click',function(){
				if($(this).data('magnify')){
					console.log($(this).attr('src'))
					layer.open({
					  type: 1,
					  title:false,
					  skin: 'layui-layer-rim', //加上边框
					  area: ['500px', '500px'], //宽高
					  content: `<img style="width: 100%;height:100%;" src="${$(this).attr('src')}" />`
					});
				}
			});
	   		}
	   	})
	}
	
	function detailauction(obj,main){
		var detail_cont=`<div class='am-u-sm-12' style='padding:10px;font-size:14px;height:100%'>
	   			<div class='am-u-sm-12 cl-p'  style='height:100%'>
	   				<div class='am-u-sm-6 cl-p'>
		   				<div class="am-u-sm-12 cl-p">
	   						<div class='am-u-sm-4' style='text-align:right'>
		   						车牌号:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						<a href='{:url("detail")}?car_id=${main.car_id}'  target="_blank">${main.number}</a>
		   					</div>
				   				
			   			</div>
			   			
		   				<div class="am-u-sm-12 cl-p">
		   					<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖申请人:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.people?main.people:'-'}
		   					</div>
		   					
			   			</div>
			   			<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						申请时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date}
		   					</div>
			   				
			   			</div>
			   			
			   			<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						审核时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   							${main.date_2}
		   					</div>
			   				
			   			</div>`
		if(obj.data('type')==3){
			detail_cont+=`
						<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖成交方:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.auction_er}
		   					</div>
		   				</div>
		   				<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date_4}
		   					</div>
			   				
			   			</div>
		   				
		   				<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						登记时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date_6}
		   					</div>
			   				
			   			</div>`;
		}else if(obj.data('type')>=4){
			detail_cont+=`
						<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖成交人:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.auction_er}
		   					</div>
		   				</div>
		   				<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						拍卖时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date_4}
		   					</div>
			   				
			   			</div>
		   				
		   				<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						登记时间:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.date_6}
		   					</div>
			   				
			   			</div>`;
		}
		detail_cont+=`<div class="am-u-sm-12 cl-p">
			   				<div class='am-u-sm-4' style='text-align:right'>
		   						成交金额:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.true_money}
		   					</div>
		   					
			   			</div>
			   			<div class="am-u-sm-12 cl-p">
		   					<div class='am-u-sm-4 ' style='text-align:right'>
		   						拍卖理由:
		   					</div>
		   					<div class='am-u-sm-8 cl-p' >
		   						${main.why}
		   					</div>
			   				<div class='am-u-sm-12'>
			   					
			   				</div>
		   				</div>
		   			</div>
		   			<div class='am-u-sm-6 ' style='height:100%'>
		   				<img class='magnifyauction' src='{$static_dir}/assets/img/noimg.gif' alt="拍卖凭证" data-magnify='1' style='height:100%;width:100%;border:1px solid #999'>
		   			</div>
	   				
				</div>
   			</div>`
		var auto = layer.open({
   		type: 1,
   		title:'车辆拍卖详情',
   		skin: 'layui-layer-rim', //加上边框
   		area: ['600px', '350px'], //宽高
   		content: detail_cont,
   		success:function(){
   			$('.car_detail').on('click',function(){
   				choosecar("{:url('detail')}?_blank=1&car_id="+$('.CarId').val(),'车辆详情')
   			})
   			$('.magnifyauction').on('click',function(){
			if($(this).data('magnify')){
				console.log($(this).attr('src'))
				layer.open({
				  type: 1,
				  title:false,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['500px', '500px'], //宽高
				  content: `<img style="width: 100%;height:100%;" src="${$(this).attr('src')}" />`
				});
			}
		});
   		}
   		})
	}
})
